package com.mdd.front.controller.yangyangLeadingEnterprise.leadingEnterpriseManager;

import com.mdd.common.aop.NotLogin;
import com.mdd.common.entity.yangyangLeadingEnterprise.*;
import com.mdd.common.entity.yangyangLeadingEnterprise.common.JsonReturn;
import com.mdd.common.entity.yangyangLeadingEnterprise.dto.AppStoreDTO;
import com.mdd.common.entity.yangyangLeadingEnterprise.param.AppStoreParam;
import com.mdd.front.service.yangyangLeadingEnterprise.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/api/app/leadingEnterpriseManagerIndexController")
@Api(tags = "领企管家")
public class LeadingEnterpriseManagerIndexController {

    @Resource
    ITAppBannerService appBannerService;

    @Resource
    ITAppStoreService appStoreService;

    @Resource
    ITAppProductService appProductService;

    @Resource
    ITAppFunctionalService appFunctionalService;

    @Resource
    ITAppPolicySubsidiesService appPolicySubsidiesService;

    @Resource
    ITAppEnterpriseQualificationService appEnterpriseQualificationService;

    @Resource
    ITAppEnterpriseCreditRepairService appEnterpriseCreditRepairService;

    @NotLogin
    @PostMapping(value = "/index",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="领企管家主页面")
    @ResponseBody
//    public String index(@RequestBody LoginParam param, HttpServletRequest request) {
    public String index(HttpServletRequest request) {
        //轮播图
        List<TAppBanner> appBannerList = appBannerService.selectList(TAppBanner.TYPE.type_pic,TAppBanner.SHOWTYPE.leading_enterprise_manager);
       //模块
        List<TAppFunctional> appFunctionalList = appFunctionalService.selectList();
        //政策补贴
        List<TAppPolicySubsidies> appPolicySubsidiesList = appPolicySubsidiesService.selectList();
        //企业资质
        List<TAppEnterpriseQualification> appEnterpriseQualificationList = appEnterpriseQualificationService.selectList();
        //门店
        AppStoreParam appStoreParam = new AppStoreParam();
        appStoreParam.setAmount(2);
//        List<TAppStore> appStoreList = appStoreService.selectList(appStoreParam);
        List<AppStoreDTO> appStoreList = appStoreService.selectDtoList(appStoreParam);
        //产品
        List<TAppProduct> productList = appProductService.selectList();
        return JsonReturn.success()
                .put("appBannerList",appBannerList)
                .put("appStoreList",appStoreList)
                .put("productList",productList)
                .put("appFunctionalList",appFunctionalList)
                .put("appPolicySubsidiesList",appPolicySubsidiesList)
                .put("appEnterpriseQualificationList",appEnterpriseQualificationList)
                .toJsonStr();
    }


    @NotLogin
    @PostMapping(value = "/selectEnterpriseCreditRepairList",produces = "application/json; charset=UTF-8")
    @ApiOperation(value="企业信用修复")
    @ResponseBody
    public String selectEnterpriseCreditRepairList(HttpServletRequest request) {

        List<TAppEnterpriseCreditRepair> appEnterpriseCreditRepairList =appEnterpriseCreditRepairService.selectList();
        return JsonReturn.success().setListData(appEnterpriseCreditRepairList).toJsonStr();
    }






}
